<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="zhangcheng">
		<title>单位帐户维护</title>
		<script language="javascript" src="../script/common.js" type="text/javascript"></script>
		<script type="text/javascript" language="JavaScript" src="../script/tree.js"></script>
		
		<!--动态js-->
<script type="text/javascript">
	var qtUnit = null;//单位qt
	var dqt = null;
	//页面加载方法
	function load(){
		Eui.showNavigation();									// 显示导航栏
		setPages(["listview","userdetaildiv","binddiv"]);						//切换页面
		var cOrg = Common.cOrg()
		$("unitForm").currentOrg.value = cOrg.id;
		$("unitForm").currentOrgLevel.value = cOrg.orgLevel;
		createUnitTable();
	}		
	//单位客户帐户列表
	function createUnitTable(){									//显示查询结果方法
		var columns = []						
		columns[2] = {render:nameFunc}
		columns[6] = {title:"操作",width:"22",render:operateFunc,order:false}
		qtUnit = new QueryTable("acc_unit_manage","unitForm","unitDataList",columns);
	}
	//处理数据 点姓名进入编辑页面
	function nameFunc(v,r){								
		return "<a href=# onclick=\"showUser("+r[0]+",true);return false;\">"+v+"<\/a>"
	}
	//列表操作链接
	function operateFunc(v,r){
		return "<a href=# onclick=showBind('"+r[0]+"')>绑定卡片<\/a>"
	}
	
	//（操作）编辑
	function showUser(id,view){								//编辑页面
		var opts = {isView:view}
		switchPage("userdetaildiv");
		CardMgnt.userDetail.show("userdetaildiv",id,null,opts)
	}
	
	function showBind(id){
		switchPage("binddiv");
		showDrivers(id)
	}
	
	function showDrivers(id){
		driversForm.orgUserId.value = id
		DWR.call("mgntQueryService.getUserInfo",id,function(data){
			Common.showDetail("companyUserDiv",CardMgnt.parseCardUser(data))
		})
		if(!dqt){
			var columns = []
			columns[0] = {type:"checkbox"}
			dqt = new QueryTable("drivers_list","driversForm","driversdiv",columns,{
				columnsConf : false,
				buttons : [
					{value:"绑定员工卡",actions:bindOrgCard},
					{value:"解除绑定",actions:unBindOrgCard}
				]
			});
		}
		dqt.showTable();
	}
	function bindOrgCard(){
		var params = {}
		params.cardTypeId = null
		params.orgUserId = driversForm.orgUserId.value;
		var url = spellUrl("/card/sel_drivers.html",params)		
		openDialogFrame(url,'选择未绑定的员工卡',500,600,function(){
			dqt.showTable();
		});
	}
	
	function unBindOrgCard(){
		var ids = dqt.getBoxValue();
		if (!ids) {showWarning("请选择需要解除绑定关系的员工！");return;}
		if (!showQuestion("是否解除与这些司机的绑定？")) return;
		DWR.call("zhgjService.unbindOrgCards",ids,function(){
			showInformation("员工与单位绑定关系已经解除");
			dqt.showTable();
		},{blockScreen:true});
	}
</script>
	</head>
	
	<body onload="load()">
		<div class="nav"><div id="nav">&nbsp;</div></div>
		<div id="listview">	
			<div class="searchForm">
				<form id="unitForm" name="unitForm">
					<input name="currentOrg" type="hidden">
					<input name="currentOrgLevel" type="hidden">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0">
						<tr>
							<td><label>单位名称</label> <input type="text" name="oname"></td>
							<td><label>客户编号</label> <input type="text" name="ooilNo" onBlur="checkV(this,'uniqueId')"></td>
							<td><button type="button" onclick="qtUnit.showTable()">查 询</button></td>
						</tr>
					</table>
				</form>
			</div>
			<div id="unitDataList"></div>
		</div>
		<div style="display:none;" id="userdetaildiv"></div>
		<div style="display:none;" id="binddiv">
			<form id="driversForm" name="driversForm" action="">
				<input type="hidden" name="orgUserId">
			</form>
			<div class="form">
				<div class="formTitle">单位帐户信息</div>
				<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="viewTable col3" id="companyUserDiv">
					<tr>
						<td width="50%"><label>名&nbsp;&nbsp;&nbsp;&nbsp;称</label> <span id="name"></span></td>
						<td><label>证件类型</label> <span id="idnoTypeText"></span></td>
						<td><label>证&nbsp;件&nbsp;号</label> <span id="idno"></span></td>
					</tr>
					<tr>
						<td width="50%"><label>客户编号</label> <span id="uniqueId"></span></td>
						<td><label>开户机构</label> <span id="buildFileStationName"></span></td>
						<td><label>状&nbsp;&nbsp;&nbsp;&nbsp;态</label> <span id="statusText"></span></td>
					</tr>
				</table>
			</div>
			<div id="driversdiv">
			</div>
		</div>
	</body>
</html>
